I am workig with jquery and php,I have input type textbox and i want to execute function by "onclick" OR "Press Enter button" But problem is ...i am trying to pass parameters (via data attributes) to anoter function then nothing works,Here is my code
<input type="text" id="txt" class="feed_in_input fi1" name="">
Here is my script
$('.fi1').keypress(function(e) {
if (e.which == 13) {
e.preventDefault();
handleClickAndEnter(e);
}
});
$('.feed_reply_smiley').on('click', function(e) {
handleClickAndEnter(e)
});
function handleClickAndEnter(e)
{
var txt_id = $(this).attr('id').replace('button', 'txt');
var vals = $('#'+txt_id).val();
var pst=$(this).data('pst');
var cst=$(this).data('cst');
var pidd=$(this).data('pidd');
alert(txt_id + vals);
.....ajax code
....
}
If i just use "onclick" function then all parameters passing properly but i want to pass parameters in both condition ("onclick" or "Press enter button") How can i do this ? Where i am wrong ? Thanks in advance